#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <string.h>

int strlen1(const char* str)
{
	int n = 0;
	//for (n = 0; *str != '\0'; n++, str++);
	while (*str != '\0')
	{
		n++;
		str++;
	}
	return n;
}

int strlen2(const char* str)
{
	if (*str == '\0')
		return 0;
	else
		return 1 + strlen2(str + 1);
}

int f1(int n)
{
	int k = 1;
	while (n > 1)
	{
		k *= n;
		n--;
	}
	return k;
}

int f2(int n)
{
	if (n <= 1)
		return 1;
	else
		return n * f2(n - 1);
}

void print(int n)
{
	if (n > 9)
	{
		print(n / 10);
	}
	printf("%d ", n % 10);
}

void reserve_string(char* string)
{
	int len = strlen(string);
	char temp = *string;
	*string = *(string + len - 1);
	*(string + len - 1) = '\0';
	if (strlen(string + 1) >= 2)
	{
		reserve_string(string + 1);
	}
	*(string + len - 1) = temp;
}
int main()
{
	char arr[] = "abcdef";
	reserve_string(arr);
	printf("%s\n", arr);
	printf("%d\n", strlen1(arr));
	printf("%d\n", strlen2(arr));
	//printf("%d\n", f1(5));
	//printf("%d\n", f2(5));
	//print(12345);
	return 0;
}